<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<body>
    <h1>用户登录</h1>
    用户名： <input type="text" name="userName" id="userName"> <br>
    密码： <input type="passWord" name="passWord" id="passWord"> <br>
    <input type="button" value="登录"  onclick="login()">

    <script src="jquery" > </script>
    <script>
        function login(){
            $.ajax({
                url:"/user/login", //路经封装
                type:"post",
                data:{
                    userName: $("#userName").val(),
                    passWord: $("#passWord").val()
                },
                success:function(result){
                    if(result){
                        location.href="index.html";
                    }else{
                        alert("用户或密码错误");
                    }
                }
            });
        }
    </script>
</body>
</html>